//
//  LKUserInfor.m
//  YLHelper
//
//  Created by she1323 on 2018/5/25.
//  Copyright © 2018年 she1323. All rights reserved.
//

#import "LKUserInfor.h"

@implementation LKUserInfor

+ (instancetype)accountWithDict:(NSDictionary *)dict
{
    NSString *workId = dict[@"id"];
    LKUserInfor *account = [LKUserInfor modelWithDictionary:dict];
    account.token = [NSString stringWithFormat:@"Bearer %@", account.token];
    workId = workId;
    return account;
}

+(void)reloadUserInformation{
    [[LKNetDataManager defaultManager] sendRequestMethod:HTTPMethodPOST serverUrl:ServerlUrl apiPath:@"" parameters:@{} progress:^(NSProgress * _Nullable progress) {
        
    } success:^(BOOL isSuccess, id  _Nullable responseObject) {
//        LKUserInfor *user = [lk]
//        LKUserInfor *userinfor = [LKUserInfor shareInfor];
//        userinfor = [LKUserInfor modelWithDictionary:responseObject[@""]];
//        [[NSNotificationCenter defaultCenter] postNotificationName:reloadUserInformationNotice object:nil];
    } failure:^(NSString * _Nullable errorMessage) {
        
    }];

}

+(NSDictionary<NSString *,id> *)modelCustomPropertyMapper{
    return @{@"workerId":@"id"};
}
-(void)encodeWithCoder:(NSCoder *)aCoder{
    [self modelEncodeWithCoder:aCoder];
}
-(instancetype)initWithCoder:(NSCoder *)aDecoder{
    return [self modelInitWithCoder:aDecoder];
}
-(id)copyWithZone:(NSZone *)zone{
    return [self modelCopy];
}
//Model 到字典

- (NSDictionary *)properties_aps

{
    
    NSMutableDictionary *props = [NSMutableDictionary dictionary];
    
    unsigned int outCount, i;
    
    objc_property_t *properties = class_copyPropertyList([self class], &outCount);
    
    for (i = 0; i < outCount; i++)
        
    {
        
        objc_property_t property = properties[i];
        
        const char* char_f = property_getName(property);
        
        NSString *propertyName = [NSString stringWithUTF8String:char_f];
        
        id propertyValue = [self valueForKey:(NSString *)propertyName];
        
        if (propertyValue) [props setObject:propertyValue forKey:propertyName];
        
    }
    free(properties);
    
    return props;
}
@end
